package com.sxkf.template.controller;

import com.sxkf.core.api.vo.R;
import com.sxkf.template.entity.Prize;
import com.sxkf.template.service.PrizeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2025-01-04 18:08:25
 */
@Api(tags = "抽奖奖品模块")
@RestController
@RequestMapping("/prize")
public class PrizeController {
    @Resource
    private PrizeService prizeService;
    
    @ApiOperation(value = "查询奖品")
    @GetMapping(value = "/list")
    public R<List<Prize>> list(){
        return R.success(prizeService.list());
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public R<?> add(@RequestBody Prize prize){
        prizeService.save(prize);
        return R.success();
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public R<?> delete(@RequestParam String id){
        prizeService.removeById(id);
        return R.success();
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public R<?> update(@RequestBody Prize prize){
        prizeService.updateById(prize);
        return R.success();
    }
}
